﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using CID.Domain.Infrastructure;

namespace CID.Web.Models.Infrastructure
{
    public class TemplateTypeViewModel : BaseDescribedViewModel<ITemplateType>
    {
        #region Properties
        public bool Enabled { get; set; }
        [Required(ErrorMessage = "You must provide the type to be used for converting the Template Content for edition")]
        [Display(Name = "Converter type for the Template's Content edition")]
        public string TemplateContentEditorConverterType { get; set; }
        [Required(ErrorMessage = "You must provide the name of the Template Content edition view")]
        [Display(Name = "View name for the Template's Content edition")]
        public string TemplateContentEditorViewName { get; set; }
        #endregion

        public TemplateTypeViewModel() : base() { }
        
        public TemplateTypeViewModel(ITemplateType model) : base(model)
        {
            Enabled = model.Enabled;
            TemplateContentEditorConverterType = model.TemplateContentEditorConverterType;
            TemplateContentEditorViewName = model.TemplateContentEditorViewName;
        }

        public override void UpdateModel(ITemplateType model)
        {
            base.UpdateModel(model);
            model.Enabled = Enabled;
            model.TemplateContentEditorConverterType = TemplateContentEditorConverterType;
            model.TemplateContentEditorViewName = TemplateContentEditorViewName;
        }

        #region Edition helper members
        public IEnumerable<string> AvailableTemplateContentEditorConverterTypes { get; set; }
        public IEnumerable<string> AvailableTemplateContentEditorViewNames { get; set; }
        #endregion
    }
}